<%@page import="entity.Pagination"%>
<%@page import="entity.Movie"%>
<%@page import="dao.MovieDao"%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

	if(session.getAttribute("admin")==null){
	response.sendRedirect("adminlogin.jsp");
}

String pageIndex = request.getParameter("pageIndex");
if (pageIndex == null) {
    pageIndex = "1";
}
request.setCharacterEncoding("utf-8");
Pagination pagination =new Pagination();
pagination.setCurrentPage(Integer.parseInt(pageIndex));
MovieDao moviedao = new MovieDao();
ArrayList<Movie> cs = moviedao.findAll(pagination);
if(cs==null)
	System.out.println("miss");
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>

<title>修改电影</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	 
<link rel="stylesheet" href="css/bootstrap.css" >

</head>
  <script src="js/jquery2.2.3.js"></script>
  <script src="js/bootstrap.js"></script>
<body>
   <nav class="navbar navbar-inverse" role="navigation">
   <div class="navbar-header">
      <a class="navbar-brand" href="index.jsp">电影网</a>
   </div>
    <div>
      <ul class="nav navbar-nav">
         <li><a href="add_movie.jsp">添加电影</a></li>
         <li><a href="update_movie.jsp">修改电影</a></li>
      </ul>

      <ul class="nav navbar-nav navbar-right">
         <li><a href="loginout.jsp">退出管理员模式</a></li>
      </ul>
</div>
</nav>

<h1 class="center-block" style="text-align:center;width:200px">
  修改电影
</h1>
  <div class="container-fluid">
	<div class="row-fluid">
			<%
				for(Movie c: cs){
			%>
			<div class="col-sm-12">
			   <div class="thumbnail" style="border-color:black">
 	 					<img src="<%=c.getPicture()%>" style="float:left;padding-top:60px;padding-left: 20px;height: 251px">
 	 				
 	 					<div class="caption" style="margin-left: 200px;margin-bottom: 230px"> 	 					
            				<h2><a href="detail.jsp?id=<%=c.getMid()%>" style="text-decoration: none"><%=c.getName() %></a>
            				<span class="label label-default" >￥<%=c.getPrice() %></span><button class="btn btn-warning pull-right" onclick="window.location.href='delete_movie.jsp?id=<%=c.getMid()%>'">删除</button> </h2>
            				<div style="float:left;margin-top:10px">
            				<p>导演：<%=c.getDirector() %></p>
            				<p>主演：<%=c.getActor() %></p>
            				<p>类型：<%=c.getType() %></p>
            				<p>时长：<%=c.getLength() %>分钟</p>
            				<p>评分：<%=c.getMark() %></p>
            				<small><%=c.getIntroduce() %></small>
            				
            				</div>
            				
            			</div> 					
 	 				</div>
			</div>
			<%
				}
			%>
			<div class="col-sm-9">
<ul class="pagination pull-left">
<li><a href="update_movie.jsp?pageIndex=1">首页</a></li>
<li><a href="update_movie.jsp?pageIndex=<%=pagination.getCurrentPage()-1%>">上页</a></li>
<li><a  href="update_movie.jsp?pageIndex=<%=pagination.getCurrentPage()+1%>">下页</a></li>
<li> <a href="update_movie.jsp?pageIndex=<%=pagination.getTotalPage()%>" > 末页</a> </li>
</ul>
<p style="padding-top:24px;margin-left:240px">共<%=pagination.getTotalRow()%>条记录，当前第<%=pagination.getCurrentPage()%>页/共<%=pagination.getTotalPage()%>页 </p>
</div>
  </div>	
 </div>

</body>
</html>